home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Spiral wipe.c < prev    next >
Text File  |  1993-08-23  |  3KB  |  89 lines

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define BOXSIZE 20
  15. #define CorrectTime 1
  16.  
  17. void SpiralGyra(GrafPtr);
  18.  
  19. /* Start in the topleft corner, facing downwards.  Copy until you hit (a) the
  20.    edge of the screen, or (b) bits you've already copied.  Then turn counter-
  21.    clockwise and do it again.  */
  22.    
  23. void SpiralGyra(GrafPtr sourceGrafPtr)
  24. {
  25.     int        stop,sbottom,sleft,sright,iterrow,itercol,direction;
  26.     Rect    source;
  27.     Boolean    everyOther;
  28.     
  29.     everyOther=FALSE;
  30.     stop=0;
  31.     sbottom=MAIN_WINDOW_HEIGHT/BOXSIZE-(MAIN_WINDOW_HEIGHT%BOXSIZE ? 0 : 1);
  32.     sleft=0;
  33.     sright=MAIN_WINDOW_WIDTH/BOXSIZE-(MAIN_WINDOW_WIDTH%BOXSIZE ? 0 : 1);
  34.     direction=3;
  35.     iterrow=stop;
  36.     itercol=sleft;
  37.     while ((stop<=sbottom)&&(sleft<=sright))
  38.     {
  39.         StartTiming();
  40.         source.top=iterrow*BOXSIZE;         /* Yes, I know I should recode this */
  41.         source.bottom=source.top+BOXSIZE;   /* to take out multiplication. */
  42.         source.left=itercol*BOXSIZE;        /* If it matter that much to you, */
  43.         source.right=source.left+BOXSIZE;   /* you do it. */
  44.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  45.             &source, &source, 0, 0L);
  46.         switch (direction)
  47.         {
  48.             case 0:  /* facing right */
  49.                 if (itercol==sright)
  50.                 {
  51.                     sbottom--;
  52.                     direction++;
  53.                     iterrow--;
  54.                 }
  55.                 else itercol++;
  56.                 break;
  57.             case 1:  /* facing up */
  58.                 if (iterrow==stop)   /* that reads "s top," not "stop" */
  59.                 {
  60.                     sright--;
  61.                     direction++;
  62.                     itercol--;
  63.                 }
  64.                 else iterrow--;
  65.                 break;
  66.             case 2:  /* facing left */
  67.                 if (itercol==sleft)
  68.                 {
  69.                     stop++;
  70.                     direction++;
  71.                     iterrow++;
  72.                 }
  73.                 else itercol--;
  74.                 break;
  75.             case 3:  /* facing down */
  76.                 if (iterrow==sbottom)
  77.                 {
  78.                     sleft++;
  79.                     direction=0;
  80.                     itercol++;
  81.                 }
  82.                 else iterrow++;
  83.                 break;
  84.         }
  85.         if (everyOther)
  86.             TimeCorrection(CorrectTime);
  87.         everyOther=!everyOther;
  88.     }
  89. }